import { defineStore } from "pinia";

export const useUserStore = defineStore("user", {
  state: () => ({
    token: "",
    userInfo: {},
    persist: true,
    avator: "",
  }),
  actions: {
    setToken(token) {
      this.token = token;
      sessionStorage.setItem("token", token);
    },
    setInfo(user) {
      this.userInfo = user;
    },
    remove() {
      sessionStorage.clear();
      this.userInfo = {};
    },
    setAvatar(val) {
      this.avator = val;
    },
  },
});
